App({
    data: {
        userInfo: null,
        all: null
    },
    onLaunch() {
      let self = this
      wx.login({
          success: (res) => {
              wx.request({
                  url: 'https://xiongmaoyin.com/api/join',
                  method: 'POST',
                  data: {
                      jscode: res.code
                  },
                  success: (res) => {
                        if(res.data.result.code == 200) {
                            wx.setStorageSync('token', res.data.result.data)
                            wx.getUserInfo({
                                success: (res) => {
                                    self.data.userInfo = res.userInfo
                                }
                            })
                        }
                  }
              })
              
          }
      })
      wx.request({
          url: 'https://xiongmaoyin.com/api/all',
          method: 'POST',
          success: (res) => {
              if(res.data.code == 200) {
                  let baseUrl = 'https://xiongmaoyin.com'
                  let all = res.data.data
                  for(let i in all) {
                      all[i].cover = baseUrl + all[i].cover
                      for(let m in all[i].color) {
                          all[i].color[m].cover = baseUrl + all[i].color[m].cover
                      }
                  }
                  self.data.all = all        
              }
          }
      })
    }
})